<template>
	<view style="padding-bottom:80rpx;">
		<bs-navbar v-if="status===''" title="档案申报"></bs-navbar>
		<bs-navbar v-else :title="'档案申报('+statusList[status]+')'"></bs-navbar>
		<u-cell-group v-if='myRecord'>
			<u-cell-item :value-style='valueStyle' :title-style='titleStyle' :arrow='false' title="档案类型" value="企业档案"></u-cell-item>
			<u-cell-item :value-style='valueStyle' :title-style='titleStyle' :arrow='false' title="公司名称" :value="form.name"></u-cell-item>
			<u-cell-item :value-style='valueStyle' :title-style='titleStyle' :arrow='false' title="类型" :value="form.shoolName"></u-cell-item>
			<u-cell-item :value-style='valueStyle' :title-style='titleStyle' :arrow='false' title="法人代表" :value="form.professional"></u-cell-item>
			<u-cell-item :value-style='valueStyle' :title-style='titleStyle' :arrow='false' title="主营业务" :value="form.jobResume"></u-cell-item>
			<u-cell-item :use-label-slo='true' :value-style='valueStyle' :title-style='titleStyle' :arrow='false' title="主营业务图">
				<view class="" slot="label" @click="handBigImg(form.productionName,0)">
					<u-image border-radius='8' :fade="true" duration="450" width="180rpx" height="180rpx" :src="form.productionName"></u-image>
				</view>
			</u-cell-item>
			<u-cell-item :value-style='valueStyle' :title-style='titleStyle' :arrow='false' title="公司简介" :value="form.educationExperience"></u-cell-item>
			<u-cell-item :use-label-slo='true' :value-style='valueStyle' :title-style='titleStyle' :arrow='false' title="公司简介图">
				<view @click="handBigImg(form.professionalCategory,0)" class="" slot="label">
					<u-image border-radius='8' :fade="true" duration="450" width="180rpx" height="180rpx" :src="form.professionalCategory"></u-image>
				</view>

			</u-cell-item>
			<u-cell-item :value-style='valueStyle' :title-style='titleStyle' :arrow='false' title="单位详细地址" :value="form.companyAddress"></u-cell-item>
			<view v-for="(item,index) in form.workPerformance" :key='index'>
				<u-cell-item :use-label-slo='true' :value-style='valueStyle' :title-style='titleStyle' :arrow='false' :title="'作品('+ (index+1) +')'">
					<view class="lable-box" slot="label">
						<scroll-view :scroll-x="true" style="width:100%;display: flex;">
							<view @click="handBigImg(item.img,itemImgIndex)" class="label-img-list" v-for='(itemImg,itemImgIndex) in item.img'>
								<u-image border-radius='8' :fade="true" duration="450" width="180rpx" height="180rpx" :src="itemImg.url"></u-image>
							</view>
						</scroll-view>
					</view>
				</u-cell-item>
				<u-cell-item :value-style='valueStyle' :title-style='titleStyle' :arrow='false' :title="'作品('+ (index+1) +')'"
				 :value="item.text"></u-cell-item>
			</view>
		</u-cell-group>
		<noRecord v-else></noRecord>
	</view>
</template>

<script>
	import noRecord from './components/no-record.vue'
	export default {
		components: {
			noRecord
		},
		data() {
			return {
				myRecord: null,
				titleStyle: {
					fontWeight: "bold",
					color: '#303030',
					fontSize: '28rpx'
				},
				valueStyle: {
					color: '#666666',
					fontSize: '32rpx'
				},
				status: '',
				form: {},
				statusList: ['审核中', '审核通过', '审核失败']
			};
		},
		onLoad() {
			this.init()
		},
		methods: {
			//查看作品大图
			handBigImg(itemImg, index) {
				if (typeof(itemImg) == 'string') {
					uni.previewImage({
						current: index,
						urls: [itemImg]
					})
					return
				}
				let newImgs = []
				itemImg.forEach(item => {
					newImgs.push(item.url)
				})
				uni.previewImage({
					current: index,
					urls: newImgs
				})
			},
			async init() {
				let res = await this.$u.api.selectMyAwardOne({
					page: 1,
					pageSize: 10,
					declareType: 1,
				})
				// declareId
				this.myRecord = res
				if (this.myRecord) {
					//0审核中,1审核完成,2审核失败
					this.status = res.status
					this.form = await this.$u.api.selectOneAwardDeclare({
						declareId: res.declareId
					})
				}
				console.log(this.form, '查询申报状态', res)
			}
		}
	}
</script>

<style lang="scss">
	.u-cell {
		overflow: hidden;
	}

	.lable-box {
		white-space: nowrap;
		width: 690rpx;
		overflow: hidden;
	}

	.label-img-list {
		display: inline-block;
		// @include my-flex($fw: npwrap);
		overflow: hidden;
		white-space: nowrap;
		width: 180rpx;
		height: 180rpx;
		margin-right: 20rpx;

	}
</style>
